//////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////


#ifndef CANVASQUEBRA_H
#define CANVASQUEBRA_H

#include <canvasgl.h>

class drawGRA;
class acmFrame;
class QLabel;
//
//////////////////////////////////////////////////////////////////////////
class canvasAppl : public canvasgl
{
  Q_OBJECT

public:
    canvasAppl(QWidget *parent);
    ~canvasAppl();
    //
    //////////////////////////////////////////////////////////////////////////
    void redraw( QPainter *g );

    void findMaxMin(double *xmin, double *xmax, double *ymin, double *ymax);

    // mouse events
    //////////////////////////////////////////////////////////////////////////
    void mousePressedWC ( QMouseEvent *e, QPointF *pt );
    void mouseDraggedWC ( QMouseEvent *e, QPointF *pt );
    void mouseReleasedWC( QMouseEvent *e, QPointF *pt );

    // set model to display
    void setModel (acmFrame *model);

    // set labels
    void setMessAndPosLabel (QLabel *messageLabel, QLabel *positionLabel);

    // 
    void createCurve (char *_type);

    // 
    void editEntity (char *_type);

    //
    void selectEntity ( );

    //
    void zoomWin ( );

    // 
    void setState (int state) { m_state = state; };

    acmFrame *getCurrModel ( ) { return m_currModel; }

private:

  // grid and snap
  bool    m_grid;
  bool    m_axis;

  double m_grid_step;
  double m_grid_orig_x;
  double m_grid_orig_y;
  int    m_snap_to_grid;
  int    m_vert_mark;

  void displayAxis (drawGRA *g); 
  void displayGrid (drawGRA *g);

  void drawToler (drawGRA *g, double x, double y);

  double computeRefSize ( );


  // virtual draw
  drawGRA *currDraw;

  // current model
  acmFrame *m_currModel;

  // label to message and position
  QLabel *m_messageLabel;
  QLabel *m_positionLabel;

  // current state:
  // 0 - selection
  // 1 - add curve
  // 2 - zoom
  // 3 - curve edition (rotation, translation...)
  // 4 - pam
  int m_state;

    
};

#endif // CANVASQUEBRA_H
